package ee.falcon.controller.profile;

import java.util.Map;
import javax.swing.DefaultListModel;
import ee.falcon.xml.SpecificProfileInfo;

public class ProfilesFrameJListEditor 
{
	private Map<String, SpecificProfileInfo> profileInfoHashMap; 
	private DefaultListModel<SpecificProfileInfo> defaultListModel; 
	
	public ProfilesFrameJListEditor(DefaultListModel<SpecificProfileInfo> defaultListModel, Map<String, SpecificProfileInfo> profileInfoHashMap) 
	{
		this.defaultListModel = defaultListModel;
		this.profileInfoHashMap = profileInfoHashMap; 
	}
	
	public void renewJListData()
	{
		//Removing old JList elements
		defaultListModel.removeAllElements(); 
		for (Map.Entry<String, SpecificProfileInfo> entry : profileInfoHashMap.entrySet())
		{ 
			SpecificProfileInfo value = entry.getValue(); 
			defaultListModel.addElement(value); //elements to JList
		}
	}
	
	public void initializeJListProfilesData()
	{
		for (Map.Entry<String, SpecificProfileInfo> entry : profileInfoHashMap.entrySet())
		{
			SpecificProfileInfo value = entry.getValue();
			defaultListModel.addElement(value); //adding elements to JList
		} 
	}
	
	//[START]GETTERS AND SETTERS
	public DefaultListModel<SpecificProfileInfo> getDefaultListModel()
	{
		return this.defaultListModel; 
	}
	
	public Map<String, SpecificProfileInfo> getProfileInfoHashMap()
	{
		return this.profileInfoHashMap;
	}
	//[END]GETTERS AND SETTERS
}
